<%-- 
    Document   : pagarConta
    Created on : 12/11/2011, 21:10:12
    Author     : KOMATSU
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <script type="text/javascript">

function habilitaText(obj,id) {
if(obj.checked == true){
document.getElementById(id).disabled = false;
}else{
document.getElementById(id).disabled = true;
}
}
function desabilitaText(obj,id) {
if(obj.checked == true){
document.getElementById(id).disabled = true;
}else{
document.getElementById(id).disabled = false;
}
}
</script>
    <body><div id="container"><div id="content">
        <%@include file="topo.jsp" %>
        <%@ page import="br.objetos.*, java.util.*" %>
         <%
            MesaMetodos m = new MesaMetodos();
            m.getM().setIdMesa(request.getParameter("idm").toString());
            if (request.getParameter("idm") != null) {
                m.buscarPedidos();
            }
           
        %>
        <table border="0" cellspacing="5" cellpadding="5" width="100%">
            <tr>
                <th>
                    <%@include file="abalaterallivre.jsp" %>
                    
                </th>
            </tr><tr>
                <th align="left">
                    <h1>Pagar Conta</h1>
                     <form action="controleMesaDo.jsp?estado=pagar" method="post">
                         Mesa: <input readonly="true" type="text" value="<%=request.getParameter("idm")%>" name="idm" size="3">
                       <table border="1" cellspacing="2">
                        <thead>
                            <tr>
                                <th>QTD.</th>
                                <th>PRODUTO</th>
                                <th>VALOR</th>
                                <th>QTD x VALOR</th>
                            </tr>
                        </thead>
                        <tbody>
                            <%
                                 List listaP = new ArrayList();
                                 listaP = m.getListaPedidos();
                                 Double total=0.0;
                                 for (Iterator it = listaP.iterator(); it.hasNext();) {
                                                Pedido ped = (Pedido) it.next();
                                                Double res = Double.parseDouble(ped.getQtde())
                                                        *ped.getPreco();
                                                total=total+res;
                            %>
                            <tr>
                                <th>
                                    <%=ped.getQtde() %>
                                </th>
                                <th>
                                    <%=ped.getProduto().getTipo()%>
                                </th>
                                <th>
                                    <%=ped.getPreco()%>
                                </th>
                                <th>
                                    <%=res%>
                                </th>

                            </tr>
                            <%
                                            }
                            %>
                            <tr>
                                <th>
                                </th>
                                <th>
                                </th>
                                <th>
                                    TOTAL:
                                </th>
                                <th>
                                    <%=total%>
                                </th>
                            </tr>
                            
                                    
                        </tbody>
                        
                    </table>
                    <table border="0" cellspacing="0">
                        <tr>
                            <th align="left">
                                <P>Escolha o tipo de pagamento:
                            </th>
                        </tr>
                        <tr>
                            <th align="left">
                                <INPUT TYPE=RADIO NAME="pag" VALUE="Dinheiro" onClick="desabilitaText(this,'tx1');" CHECKED>Dinheiro<BR>
                                <INPUT TYPE=RADIO NAME="pag" VALUE="Cartao de credito" onClick="desabilitaText(this,'tx1');">Cartão de crédito<BR>
                                <INPUT TYPE=RADIO NAME="pag" VALUE="Cheque" onClick="habilitaText(this,'tx1');" >Cheque
                                <input value="Digite CPF ..." type="text" name="cpf" size="11" id="tx1" disabled="disabled" >
                            </th>
                        </tr>
                        <%if (request.getParameter("insertedCliente") != null) {
                        %>
                        <tr>
                                    <th>
                                        Este cliente não está cadastrado...
                                    </th>
                                </tr>
                        <%
                            }
                        %>
                                 
                                <tr>
                                    <th>
                                        <input type="submit" value="Encerrar" />
                                    </th>
                                </tr>
                    </table>
                                
                        
                                
                    
                    </form>
                </th>
            </tr>
        </table>
            
    </div><div id="footer" align="center"><%@include file="footer.jsp" %></div></div></body>
</html>
